package com.example.demo.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Order;
import com.example.demo.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServer extends ServiceImpl<OrderMapper,Order> {

    OrderMapper orderMapper;
    @Autowired
    OrderServer(OrderMapper mapper){
        this.orderMapper=mapper;
    }

    public List<Order> getAll(){
        return orderMapper.getAll();
    }

    public Order getById(Long id) {
        return orderMapper.getById(id);
    }

    public Long insert(Order entity){

        long sum=orderMapper.insert(entity);
        return sum;
    }

    public boolean update(Order entity){
        return orderMapper.update(entity) > 0;
    }
    public boolean delete(Long id) {
        int result=orderMapper.deleteById(id);
        return result > 0;
    }
}
